/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.bar.model;

import com.bar.service.MailingLocalServiceUtil;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.model.impl.BaseModelImpl;

import java.io.Serializable;

import java.lang.reflect.Proxy;

import java.util.Date;

/**
 * @author pgonzalm
 */
public class MailingClp extends BaseModelImpl<Mailing> implements Mailing {
	public MailingClp() {
	}

	public Class<?> getModelClass() {
		return Mailing.class;
	}

	public String getModelClassName() {
		return Mailing.class.getName();
	}

	public long getPrimaryKey() {
		return _mailingId;
	}

	public void setPrimaryKey(long primaryKey) {
		setMailingId(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return new Long(_mailingId);
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	public long getMailingId() {
		return _mailingId;
	}

	public void setMailingId(long mailingId) {
		_mailingId = mailingId;
	}

	public String getUserName() {
		return _userName;
	}

	public void setUserName(String userName) {
		_userName = userName;
	}

	public Date getCreateDate() {
		return _createDate;
	}

	public void setCreateDate(Date createDate) {
		_createDate = createDate;
	}

	public String getUserSurname() {
		return _userSurname;
	}

	public void setUserSurname(String userSurname) {
		_userSurname = userSurname;
	}

	public boolean getMailing() {
		return _mailing;
	}

	public boolean isMailing() {
		return _mailing;
	}

	public void setMailing(boolean mailing) {
		_mailing = mailing;
	}

	public String getEmail() {
		return _email;
	}

	public void setEmail(String email) {
		_email = email;
	}

	public long getPhone() {
		return _phone;
	}

	public void setPhone(long phone) {
		_phone = phone;
	}

	public void persist() throws SystemException {
		if (this.isNew()) {
			MailingLocalServiceUtil.addMailing(this);
		}
		else {
			MailingLocalServiceUtil.updateMailing(this);
		}
	}

	@Override
	public Mailing toEscapedModel() {
		return (Mailing)Proxy.newProxyInstance(Mailing.class.getClassLoader(),
			new Class[] { Mailing.class }, new AutoEscapeBeanHandler(this));
	}

	@Override
	public Object clone() {
		MailingClp clone = new MailingClp();

		clone.setMailingId(getMailingId());
		clone.setUserName(getUserName());
		clone.setCreateDate(getCreateDate());
		clone.setUserSurname(getUserSurname());
		clone.setMailing(getMailing());
		clone.setEmail(getEmail());
		clone.setPhone(getPhone());

		return clone;
	}

	public int compareTo(Mailing mailing) {
		long primaryKey = mailing.getPrimaryKey();

		if (getPrimaryKey() < primaryKey) {
			return -1;
		}
		else if (getPrimaryKey() > primaryKey) {
			return 1;
		}
		else {
			return 0;
		}
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		MailingClp mailing = null;

		try {
			mailing = (MailingClp)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		long primaryKey = mailing.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(15);

		sb.append("{mailingId=");
		sb.append(getMailingId());
		sb.append(", userName=");
		sb.append(getUserName());
		sb.append(", createDate=");
		sb.append(getCreateDate());
		sb.append(", userSurname=");
		sb.append(getUserSurname());
		sb.append(", mailing=");
		sb.append(getMailing());
		sb.append(", email=");
		sb.append(getEmail());
		sb.append(", phone=");
		sb.append(getPhone());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(25);

		sb.append("<model><model-name>");
		sb.append("com.bar.model.Mailing");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>mailingId</column-name><column-value><![CDATA[");
		sb.append(getMailingId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>userName</column-name><column-value><![CDATA[");
		sb.append(getUserName());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>createDate</column-name><column-value><![CDATA[");
		sb.append(getCreateDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>userSurname</column-name><column-value><![CDATA[");
		sb.append(getUserSurname());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>mailing</column-name><column-value><![CDATA[");
		sb.append(getMailing());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>email</column-name><column-value><![CDATA[");
		sb.append(getEmail());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>phone</column-name><column-value><![CDATA[");
		sb.append(getPhone());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private long _mailingId;
	private String _userName;
	private Date _createDate;
	private String _userSurname;
	private boolean _mailing;
	private String _email;
	private long _phone;
}